package com.ruoyi.web.controller.system;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.HousekeepingOrder;
import com.ruoyi.system.service.IHousekeepingOrderService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 人员订单管理Controller
 * 
 * @author ruoyi
 * @date 2021-06-16
 */
@RestController
@RequestMapping("/system/order")
public class HousekeepingOrderController extends BaseController
{
    @Autowired
    private IHousekeepingOrderService housekeepingOrderService;

    /**
     * 查询人员订单管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:order:list')")
    @GetMapping("/list")
    public TableDataInfo list(HousekeepingOrder housekeepingOrder)
    {
        startPage();
        List<HousekeepingOrder> list = housekeepingOrderService.selectHousekeepingOrderList(housekeepingOrder);
        return getDataTable(list);
    }

    /**
     * 导出人员订单管理列表
     */
//    @PreAuthorize("@ss.hasPermi('system:order:export')")
    @Log(title = "人员订单管理", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(HousekeepingOrder housekeepingOrder)
    {
        List<HousekeepingOrder> list = housekeepingOrderService.selectHousekeepingOrderList(housekeepingOrder);
        ExcelUtil<HousekeepingOrder> util = new ExcelUtil<HousekeepingOrder>(HousekeepingOrder.class);
        return util.exportExcel(list, "order");
    }

    /**
     * 获取人员订单管理详细信息
     */
//    @PreAuthorize("@ss.hasPermi('system:order:query')")
    @GetMapping(value = "/{hoId}")
    public AjaxResult getInfo(@PathVariable("hoId") Long hoId)
    {
        return AjaxResult.success(housekeepingOrderService.selectHousekeepingOrderById(hoId));
    }

    /**
     * 新增人员订单管理
     */
//    @PreAuthorize("@ss.hasPermi('system:order:add')")
    @Log(title = "人员订单管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody HousekeepingOrder housekeepingOrder)
    {
        return toAjax(housekeepingOrderService.insertHousekeepingOrder(housekeepingOrder));
    }

    /**
     * 修改人员订单管理
     */
//    @PreAuthorize("@ss.hasPermi('system:order:edit')")
    @Log(title = "人员订单管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody HousekeepingOrder housekeepingOrder)
    {
        return toAjax(housekeepingOrderService.updateHousekeepingOrder(housekeepingOrder));
    }

    /**
     * 删除人员订单管理
     */
//    @PreAuthorize("@ss.hasPermi('system:order:remove')")
    @Log(title = "人员订单管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{hoIds}")
    public AjaxResult remove(@PathVariable Long[] hoIds)
    {
        return toAjax(housekeepingOrderService.deleteHousekeepingOrderByIds(hoIds));
    }
}
